<?php
    $Profile = Dracosys::getSessionValue(SESSION_INTERFACE, 'ProfileEdit');
    $ArPositions = Dracosys::getSessionValue(SESSION_INTERFACE, 'PositionList');
    $ArActions = Dracosys::getSessionValue(SESSION_INTERFACE, 'ActionsList');
?>
<h2>Editar Perfil</h2>
<section id="EditProfile">
    <form method="post" action="serfil/atualizar" name="FormEditarPerfil">
        <section id="EditProfile_Dados" class="section-update">
            <div class="out_txt big"><label for="EditProfile_IDFuncao">Função</label></div>
            <div class="inp_txt big">
                <select name="IDFunção" id="EditProfile_IDFuncao">
                    <?php foreach($ArPositions as $Position):
                            $StSelected = $Profile->getFuncao()->equals($Position) ? 'selected="selected"' : '';
                    ?>
                        <option value="<?=$Position->getIDFuncao()?>" <?=$StSelected?> ><?=$Position->getStNome()?></option>
                    <?php endforeach; ?>
                </select>
            </div>
            <div class="out_txt big"><label for="EditProfile_StPerfil">Nome do Perfil</label></div>
            <div class="inp_txt big"><input type="text" name="StPerfil" id="EditProfile_StPerfil" value="<?=$Profile->getStPerfil()?>" /></div>
            <div class="sessionTitle">Ações deste Perfil</div>
            <?php foreach($ArActions as $Action):
                $StSelected = ($Profile->hasAction($Action)) ? 'checked="checked"' : '' ;
            ?>
                <div class="out_txt small action"><label for="EditProfile_<?=$Action->getIDAcao()?>"><?=$Action->getStAcao()?></label></div>
                <div class="inp_txt small marked"><input type="checkbox" name="Action<?=$Action->getIDAcao()?>" value="<?=$Action->getIDAcao()?>" id="EditProfile_<?=$Action->getIDAcao()?>" <?=$StSelected?> /></div>
            <?php endforeach; ?>
        </section>
        <input type="hidden" name="IDPerfil" id="EditProfile_IDPerfil" value="<?=$Profile->getIDPerfil()?>" />
        <div class="btn"><button class="v1">Atualizar</button></div>
    </form>
</section>
